package com.ysw.experience.数据类型的运用;

import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.BitFieldSubCommands;
import org.springframework.data.redis.core.BoundHashOperations;
import org.springframework.data.redis.core.BoundValueOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import java.nio.charset.StandardCharsets;
import java.time.LocalDate;
import java.util.List;

/**
 * @author: yu_sw
 * @Description: com.ysw.experience.数据类型的运用
 * @date:2022/5/27 22:16
 */
@Service
public class BitMapService {
    @Autowired
    public StringRedisTemplate redisTemplate;

    public static final String key_1 = "yusw:bitmap:1";

    public void initBitMap() {
        redisTemplate.opsForValue().setBit(key_1,0,true);
        redisTemplate.opsForValue().setBit(key_1,1,true);
        redisTemplate.opsForValue().setBit(key_1,2,false);
        redisTemplate.opsForValue().setBit(key_1,3,true);
        redisTemplate.opsForValue().setBit(key_1,4,false);
        redisTemplate.opsForValue().setBit(key_1,5,false);
        redisTemplate.opsForValue().setBit(key_1,6,false);
        redisTemplate.opsForValue().setBit(key_1,7,false);
        redisTemplate.opsForValue().setBit(key_1,8,false);
        redisTemplate.opsForValue().setBit(key_1,9,false);
        redisTemplate.opsForValue().setBit(key_1,10,true);
        redisTemplate.opsForValue().setBit(key_1,11,true);
        redisTemplate.opsForValue().setBit(key_1,12,true);
        String o = redisTemplate.opsForValue().get(key_1);
        byte[] bytes = o.getBytes(StandardCharsets.UTF_8);
        System.out.println(bytes);
    }

}
